package com.chainyoung.component_tmperson.ui.view;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.Gravity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.chainyoung.common.view.BaseDialog;
import com.chainyoung.component_tmperson.R;

public class RestoreWordsRemindDialog {

    private Context mContext;
    private BaseDialog mDialog;

    private View.OnClickListener onClickListener;

    private boolean isAgree=false;


    public RestoreWordsRemindDialog(Context context, View.OnClickListener onClickListener) {
        mContext = context;
        this.onClickListener=onClickListener;
        init();

    }


    private void init() {
        BaseDialog.Builder mBuilder = new BaseDialog.Builder(mContext);
        mDialog = mBuilder.setViewId(R.layout.layout_restore_words_remind)
                //.setAnimation(com.jingdu.gamewallet.commonlibs.R.style.Scale_aniamtion)
                .setGravity(Gravity.CENTER)
                .isOnTouchCanceled(false)
                .isCanceled(false)
                .setHeightdp(190)
                .setWidthdp(300)
                .builder();
        final TextView tvConfirm = mDialog.getView(R.id.tv_confirm);
        TextView tvCancel=mDialog.getView(R.id.tv_cancel);
        tvConfirm.setOnClickListener(onClickListener);
        tvCancel.setOnClickListener(onClickListener);
        CheckBox checkBox=mDialog.getView(R.id.cb_protocol);
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                isAgree=isChecked;
                tvConfirm.setTextColor(isChecked? ContextCompat.getColor(mContext,R.color._0078f5):ContextCompat.getColor(mContext,R.color._7e8da6));
            }
        });

    }

    public void show() {

        mDialog.show();

    }

    public void close() {
        mDialog.close();
    }

    public void setOnClickListener(View.OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }


    public boolean isAgree() {
        return isAgree;
    }
}
